package com.study.mapper;

import com.study.model.Student;
import com.study.model.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ClassMapper {
   @Select("select * from t_teacher where id = #{id}")
   Teacher getTeacherById(Integer id);

   @Select("select * from  t_student where  teacher_id=#{teacherID} ")
   Student getStudentByTeacherId(Integer tercherID);

   @Select("select  * from  t_teacher")
   @Results({
           @Result(property = "id",column = "id"),
           @Result(property = "teacher",column = "id",many = @Many(select = "getStudentByTeacherId"))
   })
   List<Teacher> getAllTeacher();

   @Select("select  * from  t_student")
   @Results({
           @Result(property = "id",column = "id"),
           @Result(property = "teacher",column = "teacher_id",one = @One(select = "getTeacherById"))
   })
   List<Student> getAllStu();

}
